import requests

with open('test.m3u8', 'r') as f:
    m3u8_data = f.read()



def parse_m3u8(m3u8_data):
    lines = m3u8_data.split('\n')

    # 提取所有ts片段URL
    ts_urls = []
    for line in lines:
        if line.endswith('.ts'):             # 简单判断ts片段
            ts_urls.append(line.strip())

    return ts_urls

ts_urls = parse_m3u8(m3u8_data)
print(ts_urls)

# https://m3u8.girigirilove.com/zijian/oldanime/2025/07/cht/9nineShihaishanoOukanCHT/01/0000.ts